package com.chenyaowei.happyhub.service;

import com.chenyaowei.happyhub.excepiton.BasicException;
import com.chenyaowei.happyhub.excepiton.ExceptionEnum;
import com.chenyaowei.happyhub.mapper.AccountMapper;
import com.chenyaowei.happyhub.pojo.wechatuser.Account;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
@AllArgsConstructor
@Slf4j
public class AuthService {
    @Resource
    private AccountMapper accountMapper;
    public Account selectAccountByOpenid(String openid){
        if(StringUtils.isBlank(openid)){
            throw new BasicException(ExceptionEnum.PARAM_EXCEPTION.customMessage("openid is null"));
        }
        return accountMapper.selectAccountByOpenid(openid);
    }
    public void register(Account account){
        accountMapper.insertAccount(account);
    }
}
